<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Setup extends MX_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('users/auth');
		$this->load->library('form_validation');
		$this->lang->load('users/user');
		$this->lang->load('admin/admin');
		
		$this->load->model('users/user_roles_m');
		$this->load->model('users/users_m');
		
		// TODO: Temporary Code
		$this->load->model('student/student_m', 'student');
		$this->load->model('admin/setup_m', 'numbering');
		
		$this->template
				->set_theme('default')
				->set_layout('default')
				->append_metadata($this->asset->css('reset.css'))
				->append_metadata($this->asset->css('admin/app.css'))
				->append_metadata($this->asset->css('admin/default.css'))
				->append_metadata($this->asset->css('general.css'))
				->append_metadata($this->asset->css('notifcation.slider.css'))
				->append_metadata($this->asset->css('admin/jquery.accordion.css'))
				->append_metadata($this->asset->js('jquery/jquery-1.6.2.min.js'))
				->append_metadata($this->asset->js('jquery.freeow.js'))
				->append_metadata($this->asset->js('notificationBox.jquery.js'))
				->append_metadata($this->asset->js('jquery_accordion_init.js'))
				->set_breadcrumb('Home','dashboard')
		   		->set_partial('header', 'partials/header')
				->set_partial('breadcrumb','partials/breadcrumb')
                ->set_partial('footer', 'partials/footer')
				->set_partial('navigation','partials/admin/menu')
                ->set_layout('default')
				->set_theme('default');
		
    }
	
	public function index()
	{
		$this->numbering();
	}
	
	public function numbering()
	{
		$data['page_label'] = 'AUTO-GENERATED NUMBERING';
		
		$data['numberings'] = $this->numbering->get_numbering();
		
		$this->template
				->append_metadata($this->asset->js('jquery.tab.init.js'))
				->append_metadata($this->asset->css('admin/jquery.tab.css'))
				->set_breadcrumb('Student','student/lists')
				->set_breadcrumb('New')
				->build('admin/setup/numbering', $data);
	}
	
	public function update()
	{
		$data = array(
			'type'			=> $this->input->post('autogen_type'),
			'prefix'		=> $this->input->post('autogen_prefix'),
			'suffix'		=> $this->input->post('autogen_suffix'),
			'min_digit'		=> $this->input->post('autogen_min_digits'),
			'init_number'	=> $this->input->post('autogen_initial_number'),
			'current_number'=> $this->input->post('autogen_current_number')
		);
		
		$this->numbering->update_numbering($data);
		
		redirect('admin/setup');
	}
}